
/********************************************************

 * Custom Javascript code
 *
 *******************************************************/

// floatable-Menu-Container

$(document).ready(function(){
	$(window).scroll(function(){
		var scrollTop = 90;
		if($(window).scrollTop() >= scrollTop){
			$('.menu-wrapper').css({
				position : 'fixed',
				top : '0'
			});
		}
		if($(window).scrollTop() < scrollTop){
			$('.menu-wrapper').removeAttr('style');	
		}
	})
})


// Expandable - Search Box 

$(function () {
    var b = "startVal";
    function a(e) {
        var d = e.parent();
        if (d && d.hasClass("search-expand")) {
            d.stop().animate({
                width: 160
            }, 160)
        }
    }
    function c(e) {
        var d = e.parent();
        if (d && d.hasClass("search-expand")) {
            d.stop().animate({
                width: 120
            }, 250)
        }
    }
    $(".search-expand").click(function (d) {
        d.stopPropagation();
        $(this).find("input").focus()
    });
    $(".search-field").focus(function (d) {
        var f = $(this);
        d.stopPropagation();
        if (f.attr(b) == f.val()) {
            f.val("")
        }
        a(f)
    }).blur(function (d) {
        var f = $(this);
        if (!f.val()) {
            f.val(f.attr(b));
            c(f)
        }
		//search functionality
    }).keypress(function (h) {
        var i, e, g, d, f;
        if (h.which == 13) {
            i = $(this);
            e = i.val();
            if (!e) {
                return
            }
            i.val("");
            i.blur();
            d = "search.php?q=" + e;
            window.open(d, "_blank")
        }
    })
});;;


//show hide elements
$('.show-hide').each(function() {
  $(this).click(function() {
	var state = 'open'; //assume target is closed & needs opening
	var target = $(this).attr('data-target');
	var targetState = $(this).attr('data-target-state');
	
	//allows trigger link to say target is open & should be closed
	if (typeof targetState !== 'undefined' && targetState !== false) {
	  state = targetState;
	}
	
	if (state == 'undefined') {
	  state = 'open';
	}
	
	$(target).toggleClass('show-hide-'+ state);
	$(this).toggleClass(state);      
  });
});






